package com.itboye.mengwu.data.repository;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;
import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.utils.BaseErrorListener;
import com.itboye.core.utils.BaseSuccessReqListener;
import com.itboye.core.utils.ByJsonRequest.Builder;
import com.itboye.mengwu.data.interfaces.IProductAsk;
import com.itboye.mengwu.data.model.AddAddressSuccessBean;
import com.itboye.mengwu.data.model.ProductAskModel;

public class ProductAskRepository extends BaseNetRepository implements
		IProductAsk {
	String apiVer = "100";
	String GoodsAsk = "BY_Product_queryFaq";
	String GoodsAskSave = "BY_Product_ask";
	String GoodsAskDetial = "BY_Product_detailFaq";
	String StoreAsk = "BY_StorePromotion_getInfo";
	String SerivceAsk = "BY_Product_getServices";

	public ProductAskRepository(ICompleteListener listener) {
		// TODO Auto-generated constructor stub
		super(listener);
	}

	@Override
	public void add(ProductAskModel model) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<ProductAskModel>() {
		}.getType();
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("pid", model.getPid());
		params.put("ask_content", model.getAsk_content());
		params.put("ask_uid", model.getAsk_uid());
		(new Builder<ProductAskModel>())
				.setTypeVerParamsAndReturnClass(GoodsAskSave, apiVer, params, type)
				.requestListener(
						new BaseSuccessReqListener<ProductAskModel>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public void delete(ProductAskModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(ProductAskModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(ProductAskModel model) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<ProductAskModel>() {
		}.getType();
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("pid", model.getPid());
		params.put("page_no", model.getPage_no());
		params.put("page_size", model.getPage_size());
		(new Builder<ProductAskModel>())
				.setTypeVerParamsAndReturnClass(GoodsAsk, apiVer, params, type)
				.requestListener(
						new BaseSuccessReqListener<ProductAskModel>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public List<ProductAskModel> queryYouHuiQuan(ProductAskModel model) {
		// TODO Auto-generated method stub
		return null;
	}

}
